﻿using AutoMapper;
using MediatR;
using S_Gridding.Api.Application.Commands.MeshType;
using S_Gridding.Api.Application.Commands.Respon;
using S_Gridding.Domains.FoundGridding;
using S_Gridding.Infrastructure.Interface.IWrite;

namespace S_Gridding.Api.Application.CommandsHanders.ResponHanders
{
    public class ResponCreateCommandsHanders : IRequestHandler<ResponCreateCommands, int>
    {
        private readonly IResponRepository _respon;
        private readonly IMapper _mapper;

        public ResponCreateCommandsHanders(IResponRepository respon, IMapper mapper)
        {
            _respon = respon;
            _mapper = mapper;
        }

        public async Task<int> Handle(ResponCreateCommands request, CancellationToken cancellationToken)
        {
            var res = _mapper.Map<Responsibilitygrid>(request);
            res.IsDel = false;
            return await _respon.AddAsync(res);
        }
    }
}
